/* -*-c++-*- */
/* osgGIS - GIS Library for OpenSceneGraph
 * Copyright 2007-2008 Glenn Waldron and Pelican Ventures, Inc.
 * http://osggis.org
 *
 * osgGIS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef _OSGGIS_FRAGMENT_FILTER_H_
#define _OSGGIS_FRAGMENT_FILTER_H_ 1

#include <osgGIS/Common>
#include <osgGIS/Filter>
#include <osgGIS/Feature>
#include <osgGIS/Fragment>

namespace osgGIS
{    
    /**
     * A filter that generates fragments from either features or other fragments.
     *
     * A FragmentFilter can accept either features or other fragments as input (i.e.,
     * you can append a FragmentFilter, a FeatureFilter, or a CollectionFilter.)
     *
     * The subclass implementation should override either one/both of the
     * feature-based process() methods, or one/both of the fragment-based
     * process() methods(). The compiler will call the appropriate method based
     * on the preceding filter in the graph.
     */
    class OSGGIS_EXPORT FragmentFilter : public Filter
    {        
    public: 
    
        /**
         * Processes a single feature into fragment(s). Override this method in
         * your implementation to convert individual features into fragments.         
         *
         * @param input
         *      Input feature
         * @param env
         *      Contextual compilation information
         * @return
         *      The converted input data. The default implementation of this
         *      method returns an empty set.
         */
        virtual FragmentList process( Feature* input, FilterEnv* env );


        /**
         * Processes a collection of features into fragments. Override this
         * method in your implementation to convert batches of features into
         * fragments.
         *
         * @param input
         *      Batch of features to convert into drawables
         * @param env
         *      Contextual compilation information
         * @return
         *      The converted input data. The default implementation of this
         *      method returns an empty set.
         */
        virtual FragmentList process( FeatureList& input, FilterEnv* env );


        /**
         * Processes a single fragment into fragment(s). Override this method
         * in your implementation to process individual drawables into more
         * fragments.
         *
         * @param input
         *      Single fragment to convert
         * @param env
         *      Contextual compilation information
         * @return
         *      The converted input data. The default implementation of this
         *      method returns the input data.
         */
        virtual FragmentList process( Fragment* input, FilterEnv* env );


        /**
         * Processes a collection of fragments into fragments. Override this
         * method in your implementation to process batches of fragments.
         *
         * @param input
         *      Batch of fragments to process
         * @param env
         *      Contextual compilation information
         * @return
         *      The converted input data. The default implementation of this
         *      method returns the input data.
         */
        virtual FragmentList process( FragmentList& input, FilterEnv* env );
        

    public: // Filter overrides (internal)

        virtual FilterState* newState() const;

    protected:        

        FragmentFilter();
        FragmentFilter( const FragmentFilter& rhs );
        virtual ~FragmentFilter();
    };
}

#endif // _OSGGIS_FRAGMENT_FILTER_H_
